package unit4.part1;

/**
 * 4.1.3.创建对象
 */
public class ObjectTest {
    public static void main(String[] args) {
        // 声明 + 创建 + 初始化
        Person personA = new Person();
        personA.name = "ZhangSan";
        System.out.println(personA);

        // 声明 + 创建
        Person personB = new Person("LiSi");
        System.out.println(personB);
    }
}

class Person {
    String name;

    Person() {
    }

    Person(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return "Person{" +
                "name='" + name + '\'' +
                '}';
    }
}
